package com.ap.core.ldap.dao.api;


import com.ap.core.ldap.domain.LdapAttribute;
import com.ap.core.ldap.domain.LdapZappUser;

import javax.naming.Name;
import java.util.List;

/**
 * Generic Dao interface for ladap operations
 * @param <T> Type of ldap entity
 */
public interface LdapGenericDao<T> {

    /**
     * Find all the ldap entries for specified objectClassName
     * @param objectClassName - object class name
     * @return - List of ldap entities
     */
    List<T> findAll(String objectClassName);

    /**
     * Persist ldap user or modify if already existed
     * @param ldapUser - ldap user
     * @return - persisted/modified ldap entity
     */
    void persist(T ldapUser);

    /**
     * Add attribute to ldap attribute property
     * @param ldapAttribute
     */
    void addAttribute( LdapAttribute<?> ldapAttribute);

    /**
     * Delete entry from ldap
     * @param distinguishedName
     */
    void delete(Name distinguishedName);

    /**
     * Find by ldap attribute values
     * @param objectClassName - object class name
     * @param ldapAttributes - list of ldap attributes
     * @return - List of ldap entities
     */
    List<T> findByLdapAttribute(String objectClassName, LdapAttribute<?>... ldapAttributes);

    /**
     * Remove specified attribute
     * @param ldapAttribute
     */
    void removeAttribute(LdapAttribute<?> ldapAttribute);

    /**
     *
     * @param commonName
     * @param ldapAttribute
     */
    void merge(String commonName, LdapAttribute<?> ldapAttribute);

}
